package main

import (
	"fmt"
	"io/ioutil"
	"os"

	"gitee.com/hailaz/mediafile/util"
)

const (
	ConfigFilePath = "./config.toml"
)

var Cfg *util.Config

func main() {
	fmt.Println("start--------------------------------")
	defer fmt.Println("stop--------------------------------")

	ok1, _ := util.IsFileExists("./MediaInfo.dll")
	if !ok1 {
		util.MyLogger.Println("依赖库不存在，将自动生成库文件。请重新打开软件。")
		data, _ := Asset("dll/MediaInfo.dll")
		ioutil.WriteFile("MediaInfo.dll", data, os.ModeAppend)
	}

	Cfg, ok := util.ReadConfig(ConfigFilePath)
	if (!ok) || (!ok1) {
		return
	}
	if ok, _ := util.IsFileExists(Cfg.InputPath); !ok {
		fmt.Println("输入目录不存在")
		return
	}

	defer util.LogFile.Close()
	for _, v := range Cfg.SufList {
		util.Run(Cfg, v)
	}
}
